<?php
/**
 * Delete a golfscore
 *
 * @package Golfscore
 */

$golf_score_id = get_input('golf_score_id');
$user_giud = elgg_get_logged_in_user_guid();
$golf_score = elgg_get_golf_score(array('golf_score_id' => $golf_score_id));
if($golf_score && count($golf_score) > 0) {
	$golf_score = $golf_score[0];
	if($golf_score->user_entity_id == $user_giud) {
		if(delete_golf_score($golf_score_id)) {
			system_message(elgg_echo("golfscore:delete:success"));
			elgg_golfscore_recalculate_handicap(null, $user_giud);
		} else {
			register_error(elgg_echo("golfscore:delete:failed"));
			forward(REFERER);
		}
	}
}
$user = get_entity($user_giud);
forward("profile/$user->username");
?>